/****************************************************************************
*
*  ALi (Zhuhai) Corporation, All Rights Reserved. 2008 Copyright (C)
*
*  File: win_ali_demo.c
*
*  Description: 
*              
*  History:
*      Date        	Author             	Version     	Comment
*      ====        	======        	=======   	=======
*
****************************************************************************/
#include <sys_config.h>
#include <types.h>
#include <basic_types.h>
#include <mediatypes.h>
#include <api/libc/printf.h>
#include <api/libc/string.h>
#include <osal/osal.h>
#include <bus/hdmi/m36/hdmi_api.h>
#include <api/libosd/osd_lib.h>
#include <api/libchunk/chunk.h>

#include "osdobjs_def.h"

#include "string.id"
#include "images.id"
#include "osd_config.h"
#include "osd_rsc.h"

#include "win_com_menu_define.h"
#include "win_com.h"
#include "menus_root.h"

#ifdef SHOW_ALI_DEMO_ON_SCREEN

/*******************************************************************************
* Objects declaration
*******************************************************************************/

extern CONTAINER g_win_ali_demo;
extern TEXT_FIELD  ali_demo_txt;
extern BITMAP    ali_demo_bmp;
static UINT16 txt_display_buffer[30];

#define TXTN_SH_IDX   WSTL_BUTTON_01_HD
#define TXTN_HL_IDX   WSTL_BUTTON_05_HD
#define TXTN_SL_IDX   WSTL_BUTTON_02_FG_HD
#define TXTN_GRY_IDX  WSTL_BUTTON_07_HD

#define CON_SH_IDX	WSTL_BUTTON_01_HD
#define CON_HL_IDX	WSTL_BUTTON_05_HD
#define CON_HL1_IDX	WSTL_BUTTON_02_HD
#define CON_SL_IDX	WSTL_BUTTON_01_HD
#define CON_GRY_IDX	WSTL_BUTTON_07_HD

#define BMP_SH_IDX   WSTL_MIXBACK_BLACK_IDX
#define BMP_HL_IDX   WSTL_MIXBACK_BLACK_IDX
#define BMP_SL_IDX   WSTL_MIXBACK_BLACK_IDX
#define BMP_GRY_IDX  WSTL_MIXBACK_BLACK_IDX

#define LDEF_CON(root, varCon,nxtObj,ID,IDl,IDr,IDu,IDd,l,t,w,h,hl,conobj,focusID)		\
    DEF_CONTAINER(varCon,root,nxtObj,C_ATTR_ACTIVE,0, \
    ID,IDl,IDr,IDu,IDd, l,t,w,h, CON_SH_IDX,hl,CON_SL_IDX,CON_GRY_IDX,   \
    NULL,NULL,  \
    conobj, ID,1)
    
#define LDEF_BMP(root,varbmp,nxtObj,ID,IDl,IDr,IDu,IDd,l,t,w,h,bmpID)		\
    DEF_BITMAP(varbmp,root,nxtObj,C_ATTR_ACTIVE,0, \
    ID,IDl,IDr,IDu,IDd, l,t,w,h, BMP_SH_IDX,BMP_HL_IDX,BMP_SL_IDX,BMP_GRY_IDX,   \
    NULL,NULL,  \
    C_ALIGN_CENTER | C_ALIGN_VCENTER, 0,0,bmpID)
    
#define LDEF_TXT1(root,varTxt,nxtObj,l,t,w,h,str)		\
    DEF_TEXTFIELD(varTxt,root,nxtObj,C_ATTR_ACTIVE,0, \
    0,0,0,0,0, l,t,w,h, TXTN_SH_IDX,CON_HL1_IDX,TXTN_SL_IDX,TXTN_GRY_IDX,   \
    NULL,NULL,  \
    C_ALIGN_LEFT | C_ALIGN_VCENTER, 0,0,0,str)


#define LDEF_DEMO(root,varCon,nxtObj,varTxt,ID,IDu,IDd,l,t,w,h,\
						hl,str) \
    LDEF_CON(root,varCon,&varTxt,ID,ID,ID,IDu,IDd,l,t,w+4,h+4,hl,&varTxt,ID)   \
	LDEF_TXT1(root,varTxt,NULL,l+10,t,w-20,h,str)

LDEF_DEMO(NULL,g_win_ali_demo,NULL,ali_demo_txt,1,0,0, \
       0,0,154,35,CON_HL1_IDX,txt_display_buffer) //40
	

static BOOL Is_Open = FALSE;

void ShowAliDemo(BOOL flag)
{
    OBJECT_HEAD* obj;
    obj = (OBJECT_HEAD*)&g_win_ali_demo;
    if(flag)
    {
        //if(menu_stack_get_top() == NULL)
        //{
            api_inc_wnd_count();
			OSD_SetTextFieldContent(&ali_demo_txt, STRING_ANSI, (UINT32)"ALi Demo");
            OSD_DrawObject(obj, C_UPDATE_ALL);
            Is_Open = TRUE;
        //}
    }
    else if(!flag)
    {
        //if(menu_stack_get_top() != NULL)
        //{
           api_dec_wnd_count();
           OSD_ClearObject(obj,0);
           Is_Open = FALSE;
        //}
    }

}
#endif

